import {ILogger} from './ILogger';
import {Logger} from './Logger'

export class LoggerManager {
    private static instance:LoggerManager;
    private logMap:Map<string, ILogger> = new Map();
    private domain:number = 0xff00

    public static getInstance():LoggerManager {
        if (!LoggerManager.instance) {
            LoggerManager.instance = new LoggerManager();
        }
        return LoggerManager.instance;
    }

    private constructor() {
    }

    createLogger(prefix:string) {
        let logValue = this.logMap.get(prefix)
        if (logValue == undefined) {
            logValue = new Logger(prefix, ++this.domain)
            this.logMap.set(prefix, logValue)
        }
        return logValue
    }
}